<template>
  <div class="container">
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item
        ><span style="color: #417ced">仓库管理</span></el-breadcrumb-item
      >
      <el-breadcrumb-item>内部出库</el-breadcrumb-item>
    </el-breadcrumb>
    <div class="tab" style="padding-bottom: 0">
      <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="待提交" name="1"> </el-tab-pane>
        <el-tab-pane label="待审核" name="2"> </el-tab-pane>
        <el-tab-pane label="已驳回" name="3"> </el-tab-pane>
        <el-tab-pane label="待发货" name="4"> </el-tab-pane>
        <el-tab-pane label="已完成" name="5"> </el-tab-pane>
      </el-tabs>
    </div>
    <el-collapse-transition>
      <div class="inquiry" style="margin-top: 10px" v-show="!show3">
        <div class="header">
          <span>数据查询</span>
          <p @click="show3 = true">收起</p>
        </div>
        <el-form :inline="true" ref="form" :model="queryForm" size="mini">
          <el-form-item label="收货人">
            <el-input
              placeholder="请输入收货人姓名"
              v-model="queryForm.consignee"
            ></el-input>
          </el-form-item>

          <el-form-item label="订单编号">
            <el-input
              v-model="queryForm.orderId"
              placeholder="请输入订单编号"
            ></el-input>
          </el-form-item>

          <el-form-item label="部门选择">
            <div class="selectTree">
              <treeselect
                :options="options"
                v-model="queryForm.consigneeDepaCode"
                search-nested
                :normalizer="normalizer"
                noResultsText="未找到"
                placeholder="请选择"
              >
              </treeselect>
            </div>
          </el-form-item>

          <el-form-item label="出库类型">
            <el-select
              clearable
              v-model="queryForm.typeId"
              placeholder="选择订单状态"
            >
              <el-option
                v-for="items in status"
                :key="items.id"
                :label="items.deliveryName"
                :value="items.id"
              ></el-option>
            </el-select>
          </el-form-item>

          <div class="selectDate">
            <span>时间</span>
            <div class="picker">
              <el-date-picker
                clearable
                v-model="queryForm.date"
                type="daterange"
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                format="yyyy- MM- dd"
                value-format="yyyy-MM-dd"
              >
              </el-date-picker>
            </div>
          </div>

          <el-form-item label="地区">
            <levelAddr
              class="addressContent"
              :province="queryForm.province"
              :city="queryForm.city"
              :area="queryForm.area"
              @updateprovice="getProvince"
              @updatecity="getCity"
              @updatearea="getArea"
            ></levelAddr>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="searchEvent">搜索</el-button>
            <el-button @click="reset">重置</el-button>
            <!-- <el-button @click="delivery = true">弹框</el-button> -->
          </el-form-item>
          <!-- </div> -->
        </el-form>
      </div>
    </el-collapse-transition>
    <div class="btns">
      <div>
        <el-button type="primary" size="mini" @click="zhanKai">展开</el-button>
        <el-button size="mini" @click="(expends = []), (isGb = true)"
          >关闭</el-button
        >

        <el-button
          v-if="activeName != '5'"
          type="primary"
          size="mini"
          @click="addInternal"
          >添加内部出库</el-button
        >

        <el-button v-else type="primary" size="mini" @click="exportTo">导出</el-button>

        <el-button
          type="primary"
          size="mini"
          @click="exportOrder(1)"
          v-if="activeName == '5'"
          >导出财务报表</el-button
        >
        <el-button
          type="primary"
          size="mini"
          @click="exportOrder(2)"
          v-if="activeName == '4'"
          >导出订单发货信息</el-button
        >
      </div>
      <el-button type="primary" size="mini" v-if="show3" @click="show3 = false"
        >搜索展开</el-button
      >
    </div>

    <div class="table">
      <el-table
        @selection-change="multipleSelection = $event"
        ref="multipleTable"
        :data="tableData.list"
        style="width: 100%"
        :expand-row-keys="expends"
        :row-key="getRowKeys"
      >
        <el-table-column v-if="activeName == 5" type="selection" width="55">
        </el-table-column>
        <el-table-column type="index" label="序号" width="50"></el-table-column>
        <el-table-column type="expand" :show-overflow-tooltip="true">
          <template slot-scope="props">
            <div>
              <el-form class="demo-table-expand">
                <el-form-item>
                  <p
                    v-for="items in props.row.interiorOrderCommodities"
                    :key="items.id"
                  >
                    <span>{{ items.commodityName }}</span>
                    <span>
                      {{ items.price }} × {{ items.number }} =
                      {{ items.price * items.number }} 元</span>
                  <span v-if="items.goodsType=='赠品'" class="gift">赠品</span>
                  </p>
                </el-form-item>
                <!-- <el-form-item
                  v-if="!is_null(props.row.interiorOrderComplimentaries)"
                >
                  <span style="color: red">附属品：</span>
                  <p
                    class="complimentary"
                    v-for="items in props.row.interiorOrderComplimentaries"
                    :key="items.id"
                  >
                    <span>{{ items.complimentaryName }}</span>
                    <span>
                      {{ items.price }} × {{ items.number }} =
                      {{ items.price * items.number }} 元</span
                    >
                  </p>
                </el-form-item> -->
              </el-form>
            </div>
          </template>
        </el-table-column>
        <el-table-column label="订单编号" prop="orderId">
          <template slot-scope="scope">
            <span
              style="cursor: pointer"
              @click="InternalOrderDetailTo(scope.row.orderId)"
              >{{ scope.row.orderId }}</span
            >
          </template>
        </el-table-column>
        <el-table-column label="出库类型" prop="typeName"></el-table-column>
        <el-table-column label="收货人">
          <template slot-scope="scope">
            <p>{{ scope.row.consignee }}</p>
            <p>{{ scope.row.receivingPhone }}</p>
          </template>
          receivingPhone
        </el-table-column>
        <el-table-column label="订单状态" width="150">
          <template slot-scope="scope">
            <p v-if="scope.row.orderStatus == 1">待提交</p>
            <p v-if="scope.row.orderStatus == 2">审核中</p>
            <p v-if="scope.row.orderStatus == 3">驳回</p>
            <p v-if="scope.row.orderStatus == 4">待发货</p>
            <p v-if="scope.row.orderStatus == 5">已发货</p>
            <p v-if="scope.row.orderStatus == 6">待签收</p>
            <p v-if="scope.row.orderStatus == 7">已签收</p>
            <p v-if="scope.row.orderStatus == 8">已退货</p>
            <p>制单人：{{ scope.row.createdName }}</p>
          </template>
        </el-table-column>
        <el-table-column label="金额">
          <template slot-scope="scope">
            <p>总价：{{ scope.row.total }}</p>
            <p>已收：{{ scope.row.receivedMoney }}</p>
            <p>代收：{{ scope.row.awaitIncomeMoney }}</p>
          </template>
        </el-table-column>
        <el-table-column label="收货信息" min-width="100">
          <template slot-scope="scope">
            <span>{{ scope.row.address + scope.row.addressDetails }}</span>
          </template>
        </el-table-column>

        <el-table-column label="备注" prop="comment"></el-table-column>

        <el-table-column label="审核" width="100">
          <template slot-scope="scope">
            <el-popover
              placement="top-start"
              title="审批备注"
              width="200"
              trigger="hover"
              :content="scope.row.rejectReason"
            >
              <p slot="reference" v-if="scope.row.managerName">
                {{ scope.row.managerName }}
              </p>
              <p slot="reference" v-else>/</p>
            </el-popover>
          </template>
        </el-table-column>

        <el-table-column label="下单时间" prop="total" width="100">
          <template slot-scope="scope">
            <span>{{ $moment(scope.row.createdTime) }}</span>
          </template>
        </el-table-column>

        <el-table-column label="操作" min-width="150px">
          <template slot-scope="props">
            <!-- 待提交 -->
            <div class="btn" v-if="activeName == 1">
              <span
                v-if="
                  parArray.indexOf('inSubimit') != -1 &&
                  props.row.operatingStatus.indexOf('1') != -1
                "
                @click="submitTo(props.row)"
                >提交</span
              >
              <span
                v-if="
                  parArray.indexOf('inFixCode') != -1 &&
                  props.row.operatingStatus.indexOf('2') != -1
                "
                @click="updateTo(props.row.orderId)"
                >修改</span
              >
              <span
                v-if="
                  parArray.indexOf('inCloseCode') != -1 &&
                  props.row.operatingStatus.indexOf('3') != -1
                "
                @click="delectOrder(props.row, props.$index)"
                >关闭</span
              >
            </div>
            <!-- 待提交 -->
            <!-- 审核中 -->
            <div class="btn" v-if="activeName == 2">
              <span
                v-if="
                  parArray.indexOf('Inapproval') != -1 &&
                  props.row.operatingStatus.indexOf('4') != -1
                "
                @click="dowithOrder(props.row.orderId, 'approve')"
                >批准</span
              >
              <span
                v-if="
                  parArray.indexOf('inRejectCode') != -1 &&
                  props.row.operatingStatus.indexOf('4') != -1
                "
                @click="rejectionEvent(props.row)"
                >驳回</span
              >
            </div>
            <!-- 审核中 -->
            <!-- 已驳回 -->
            <div class="btn" v-if="activeName == 3">
              <span
                v-if="
                  parArray.indexOf('rejectFix') != -1 &&
                  props.row.operatingStatus.indexOf('2') != -1
                "
                @click="updateTo(props.row.orderId)"
                >修改</span
              >
              <!-- <span
                v-if="
                  parArray.indexOf('rejectAgain') != -1 &&
                  props.row.operatingStatus.indexOf('5') != -1
                "
                @click="reopenTo(props.row.orderId)"
                >重开</span
              > -->
              <span
                v-if="
                  parArray.indexOf('inCloseCode') != -1 &&
                  props.row.operatingStatus.indexOf('3') != -1
                "
                @click="delectOrder(props.row, props.$index)"
                >关闭</span
              >
            </div>
            <!-- 已驳回 -->
            <!-- 待发货 -->
            <div class="btn" v-if="activeName == 4">
              <span
                v-if="parArray.indexOf('indelivercode') != -1"
                @click="deliverGoodsUp(props.row)"
                >发货</span
              >
              <span
                v-if="parArray.indexOf('inCloseCode') != -1"
                @click="delectOrder(props.row, props.$index)"
                >关闭</span
              >
            </div>
            <!-- 待发货 -->
            <!-- 已完成 -->
            <div class="btn" v-if="activeName == 5">
              <span
                v-if="
                  parArray.indexOf('inCancelSigncode') != -1 &&
                  props.row.orderStatus != 6
                "
                @click="cancelSign(props.row)"
                >修改未签收</span
              >
              <span
                v-if="
                  parArray.indexOf('insignCode') != -1 &&
                  props.row.orderStatus != 7
                "
                @click="signOrder(props.row)"
                >签收</span
              >
              <span
                @click="logistDetail(props.row.logisticsOrder)"
                v-if="parArray.indexOf('wuliucode') != -1"
                >物流</span
              >
              <span
                v-if="
                  parArray.indexOf('backGoods') != -1 &&
                  props.row.operatingStatus.indexOf('7') != -1
                "
                @click="returnTo(props.row.orderId)"
                >退货</span
              >
            </div>
            <!-- 已完成 -->
          </template>
        </el-table-column>
      </el-table>
      <p style="height: 30px"></p>
      <!-- 分页start -->
      <div class="page" v-if="tableData.totalNum >= 0">
        <div class="block">
          <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="pageNo"
            :page-sizes="[10, 20, 50, 100, 200]"
            :page-size="pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="tableData.totalNum"
            prev-text="上一页"
            next-text="下一页"
          >
          </el-pagination>
        </div>
      </div>
      <!-- 分页end -->
    </div>
    <!-- 驳回理由 -->
    <el-dialog :visible.sync="dowithIf" :append-to-body="true" title="驳回">
      <span style="display: inline-block; line-height: 30px">驳回理由:</span>
      <el-input
        type="textarea"
        placeholder="请输入内容"
        v-model="rejectReason"
      ></el-input>
      <div slot="footer" class="dialog-footer">
        <el-button
          size="mini"
          type="primary"
          @click="dowithOrder(rejOrderId, 'rejection')"
          >驳回</el-button
        >
        <el-button size="mini" @click="dowithIf = false">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 驳回理由 -->

    <!-- 填写出库信息 -->
    <el-dialog
      :visible.sync="outWare"
      :append-to-body="true"
      title="填写出库信息"
    >
      <div class="fillin">
        <el-form ref="fillForm" :model="fillForm" label-width="80px">
          <el-form-item label="出库仓库">
            <el-select
              v-model="fillForm.ware"
              placeholder="请选择出库仓库"
              filterable
              size="mini"
            >
              <el-option
                v-for="items in warelist"
                :key="items.id"
                :label="items.name + '-(' + items.keeper + ')'"
                :value="items.id"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="物流公司">
            <el-select
              v-model="fillForm.company"
              placeholder="请选择物流公司"
              filterable
              size="mini"
            >
              <el-option
                v-for="itemsS in companys"
                :key="itemsS.dictName"
                :label="itemsS.dictName"
                :value="itemsS.dictName"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="快递单号">
            <el-input
              placeholder="请输入快递单号"
              v-model="fillForm.courier"
              size="mini"
            ></el-input>
          </el-form-item>
        </el-form>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button size="mini" type="primary" @click="outGoods()"
          >确定</el-button
        >
        <el-button size="mini" @click="outWare = false">取 消</el-button>
      </div>
    </el-dialog>
    <!-- 填写出库信息 -->
    <el-dialog
      :visible.sync="logisPoper"
      :append-to-body="true"
      title="物流查询详情"
    >
      <div v-if="logistlist.base64T === undefined">
        <p class="logHeader">
          <!-- {{logistlist.logo}} -->
          <!-- <img :src="logistlist.logo" alt="" class="images" /> -->
          <!-- <el-image :src="logistlist.logo" alt="" fit="contain">
          <div slot="error" class="image-slot">
            <i class="el-icon-picture-outline"></i>
          </div>
        </el-image> -->
          <span>{{ logistlist.expTextName }}</span>
          <span>{{ logistlist.mailNo }}</span>
        </p>
        <div v-if="logistlist.status != 1" class="trackingNode">
          <el-steps direction="vertical" :active="0">
            <el-step
              v-for="(pre, index) in logistlist.data"
              :key="index"
              class="stepSuc"
              style="flex-grow: 1; min-height: 80px"
              :title="'审批人' + pre.context"
              :description="pre.time"
            />
          </el-steps>
        </div>
        <span
          style="font-weight: 600; font-size: 18px"
          v-if="logistlist.status == 1"
          >提示暂未查询到物流信息</span
        >
      </div>
      <div
        style="
          display: flex;
          flex-direction: column;
          align-items: center;
          height: 400px;
          overflow: auto;
        "
        v-else
      >
        <div style="font-size: 20px; font-weight: 600">
          {{ logistlist.name + "    " + logistlist.id }}
        </div>
        <div>
          <img :src="'data:image/png;base64,' + logistlist.base64T" />
        </div>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import Treeselect from '@riophae/vue-treeselect'
import '@riophae/vue-treeselect/dist/vue-treeselect.css'
import levelAddr from '@/components/levelAddr'
export default {
  components: { Treeselect, levelAddr },
  data () {
    return {
      isGb: false,
      activeName: '1',
      expends: [],
      normalizer (node) {
        return {
          id: node.orgCode,
          label: node.orgName,
          children: node.children
        }
      },
      show3: false,
      parArray: [],
      queryForm: {
        consignee: '',
        typeId: '',
        orderId: '',
        consigneeDepaCode: null,
        date: '',
        province: '',
        city: '',
        area: ''
      },
      pageNo: 1,
      pageSize: 10,
      options: [],
      tableData: [],
      expandRowKeys: [],
      status: [],
      dowithIf: false,
      rejectReason: '',
      companys: [],
      warelist: [],
      outWare: false,
      fillForm: {
        ware: '',
        company: '',
        courier: ''
      },
      rejOrderId: '',
      logistlist: {},
      logisPoper: false,
      multipleSelection: []
    }
  },
  created () {
    this.listAxios() // 列表数据
    this.orderStatus() // 出库类型
    this.department() // 部门列表
    this.wareHouse()
    // 权限设定判断
    this.limits = JSON.parse(sessionStorage.getItem('limit'))
    const params = this.limits.buttonTreeDto.filter(
      (item) => item.menuCode === 'internalListCode1'
    )
    params[0].buttonList.forEach((item) => {
      this.parArray.push(item.code)
    })
    // 权限设定判断
  },
  activated () {
    this.listAxios()
  },
  methods: {
    exportTo () {
      if (!this.multipleSelection.length) {
        this.$message.warning('请选择订单')
        return
      }
      this.download(
        'order/v1/internal/interiorOrder/exportInteriorOrder',
        this.multipleSelection.map((i) => i.id),
        `config_${new Date().getTime()}.xlsx`
      ).then((res) => {})
    },
    exportOrder (type) {
      var url =
        type == 1
          ? '/order/v1/internal/interiorOrder/financialExport'
          : '/order/v1/internal/interiorOrder/selectLogisticsExport'
      let beginTime = ''
      let endTime = ''
      if (this.queryForm.date) {
        if (this.queryForm.date[0]) {
          beginTime = this.queryForm.date[0] + ' 00:00:00'
        }
        if (this.queryForm.date[1]) {
          endTime = this.queryForm.date[1] + ' 23:59:59'
        }
      }
      this.axios
        .post(
          url,
          {
            address:
              this.queryForm.province +
              this.queryForm.city +
              this.queryForm.area,
            consignee: this.queryForm.consignee,
            consigneeDepaCode: this.queryForm.consigneeDepaCode,
            endTime: endTime,
            orderId: this.queryForm.orderId,
            orderStatus: this.activeName,
            pageNo: this.pageNo,
            pageSize: this.pageSize,
            startTime: beginTime,
            typeId: this.queryForm.typeId // 出库类型id
          },
          { timeout: 60000 }
        )
        .then((res) => {
          if (res.code == 0) {
            this.downloadlink(res.data)
          } else {
            this.$message.error(res.message)
          }
        })
    },
    logistDetail: _.debounce(function (e) {
      if (!e.id) {
        this.$message.error('未找到物流信息')
      } else {
        this.axios
          .get('/order/logistics/node/tracking/' + e.id, {
            headers: {
              isLoading: true
            }
          })
          .then((res) => {
            if (res.code == 0) {
              if (res.data.data.length > 0) {
                this.logisPoper = true
                this.logistlist = res.data
              } else {
                this.$message.warning('无揽收记录')
              }
            } else {
              this.$message.error(res.message)
            }
          })
      }
    }, 300),
    zhanKai () {
      this.isGb = false
      this.tableData.list.forEach((res) => {
        this.expends.push(res.id)
      })
    },
    returnTo (id) {
      this.$router.push({
        name: 'addReturn',
        query: {
          id
        }
      })
    },
    InternalOrderDetailTo (orderId) {
      this.$router.push({
        name: 'InternalOrderDetail',
        query: {
          orderId
        }
      })
    },
    reopenTo (orderId) {
      this.$router.push({
        name: 'addInternal',
        query: {
          orderId,
          type: 2
        }
      })
    },
    // 修改跳转页面
    updateTo (orderId) {
      this.$router.push({
        name: 'addInternal',
        query: {
          orderId,
          type: 1
        }
      })
    },
    // 部门选择列表
    department () {
      this.axios
        .post(
          '/sys/v1/org/tree/select',
          {
            request: {
              orgName: '',
              orgType: ''
            },
            version: ''
          },
          {
            headers: {
              isLoading: false
            }
          }
        )
        .then((res) => {
          if (res.code == 0) {
            this.options = res.data
          } else {
            this.$message.error(res.message)
          }
        })
    },
    // 切换数据
    handleClick (e) {
      // console.log(e.name);
      this.activeName = e.name
      this.listAxios()
    },
    // 添加内部出库订单
    addInternal () {
      // this.$router.push({ name: "addInternal", query: { type: 1 } });
      this.$router.push({ name: 'addInternal', query: { type: 1 }})

      sessionStorage.removeItem('tableData')
    },
    // 提交内部出库订单
    submitTo: _.debounce(function (row) {
      this.axios
        .get(
          '/order/v1/internal/interiorOrder/submitInteriorOrder?orderId=' +
            row.orderId,
          {
            headers: {
              isLoading: false
            }
          }
        )
        .then((res) => {
          // console.log(res);
          if (res.code == 0) {
            this.$message.success('提交成功')
            this.listAxios()
          } else {
            this.$message.error(res.message)
          }
        })
    }, 300),
    // 关闭订单
    delectOrder: _.debounce(function (row) {
      this.$confirm('确定关闭该订单, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          this.axios
            .get(
              '/order/v1/internal/interiorOrder/closeInteriorOrder?orderId=' +
                row.orderId,
              {
                isLoading: false
              }
            )
            .then((res) => {
              if (res.code == 0) {
                this.$message.success('关闭成功!')
                this.listAxios()
              } else {
                this.$message.error(res.message)
              }
            })
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消删除'
          })
        })
    }, 300),
    // 驳回
    rejectionEvent (row) {
      this.rejectReason = ''
      this.dowithIf = true
      this.rejOrderId = row.orderId
    },
    // 审核订单 批准 驳货
    dowithOrder: _.debounce(function (orderId, type) {
      this.axios
        .post(
          '/order/v1/internal/interiorOrder/auditInteriorOrder',
          {
            orderId: orderId,
            rejectReason: this.rejectReason,
            type: type
          },
          {
            isLoading: false
          }
        )
        .then((res) => {
          if (res.code == 0) {
            this.$message.success('处理成功')
            this.dowithIf = false
            this.listAxios()
          } else {
            this.$message.error(res.message)
          }
        })
    }, 300),
    // 设置table中的扩展项，展开的id，此处我需要全部展开
    // 发货
    deliverGoodsUp (row) {
      this.fillForm = {
        ware: '',
        company: '',
        courier: ''
      }
      this.outWare = true
      this.outWareId = row.orderId
    },
    // 出库发货
    outGoods: _.debounce(function () {
      this.axios
        .post(
          '/order/v1/internal/interiorOrder/interiorOrderSend',
          {
            request: {
              godownOrder: '',
              handlerBy: '',
              logisticsCompany: this.fillForm.company,
              orderId: this.outWareId,
              parcelNumber: this.fillForm.courier,
              warKeeper: '',
              wareOut: this.fillForm.ware
            },
            version: ''
          },
          {
            headers: {
              isLoading: false
            }
          }
        )
        .then((res) => {
          if (res.code == 0) {
            this.$message.success('发货成功')
            this.listAxios()
            this.outWare = false
          } else {
            this.$message.error(res.message)
          }
        })
    }, 300),
    // 仓库列表
    wareHouse () {
      this.axios
        .get('/order/comm/commodity/selectCommWarehouse', {
          headers: {
            isLoading: false
          }
        })
        .then((res) => {
          //   console.log(res);
          if (res.code == 0) {
            this.warelist = res.data
          } else {
            this.$message.error(res.message)
          }
        })

      this.axios
        .get('/sys/v1/common/by/group?groupId=courier_company', {
          headers: {
            isLoading: false
          }
        })
        .then((res) => {
          // console.log(res);
          if (res.code == 0) {
            this.companys = res.data
          } else {
            this.$message.error(res.message)
          }
        })
    },

    // 确定签收
    signOrder: _.debounce(function (row) {
      const orderids = []
      orderids.push(row.orderId)
      this.$confirm('是否签收内部出库单?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          this.axios
            .post(
              '/order/v1/internal/interiorOrder/confirmSignForInteriorOrder',
              orderids,
              {
                headers: {
                  isLoading: false
                }
              }
            )
            .then((res) => {
              if (res.code == 0) {
                this.$message.success('签收成功!')
                this.listAxios()
              } else {
                this.$message.error(res.message)
              }
            })
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消签收'
          })
        })
    }, 300),

    // 取消签收
    cancelSign: _.debounce(function (row) {
      const orderids = []
      orderids.push(row.orderId)
      this.$confirm('是否取消签收内部出库单号?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          this.axios
            .post(
              '/order/v1/internal/interiorOrder/cancelSignForInteriorOrder',
              orderids,
              {
                headers: {
                  isLoading: false
                }
              }
            )
            .then((res) => {
              if (res.code == 0) {
                this.$message.success('取消签收成功!')
                this.listAxios()
              } else {
                this.$message.error(res.message)
              }
            })
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消取消签收'
          })
        })
    }, 300),
    getExpends () {
      if (!this.isGb) {
        var Id = this.tableData.list.map((item) => item.id)
        this.expends = Id
      }
    },
    getRowKeys (row) {
      return row.id
    },
    listAxios () {
      let beginTime = ''
      let endTime = ''
      if (this.queryForm.date) {
        if (this.queryForm.date[0]) {
          beginTime = this.queryForm.date[0] + ' 00:00:00'
        }
        if (this.queryForm.date[1]) {
          endTime = this.queryForm.date[1] + ' 23:59:59'
        }
      }
      this.axios
        .post('/order/v1/internal/interiorOrder/interiorOrderList', {
          address:
            this.queryForm.province + this.queryForm.city + this.queryForm.area,
          consignee: this.queryForm.consignee,
          consigneeDepaCode: this.queryForm.consigneeDepaCode,
          endTime: endTime,
          orderId: this.queryForm.orderId,
          orderStatus: this.activeName,
          pageNo: this.pageNo,
          pageSize: this.pageSize,
          startTime: beginTime,
          typeId: this.queryForm.typeId // 出库类型id
        })
        .then((res) => {
          if (res.code == 0) {
            this.tableData = res.data
            this.getExpends()
          } else {
            this.$message.error(res.message)
          }
        })
    },
    // 搜索、
    searchEvent () {
      this.pageNo = 1
      this.pageSize = 10
      this.listAxios()
    },
    handleCurrentChange (val) {
      this.pageNo = val
      this.listAxios()
    },
    handleSizeChange (val) {
      this.pageSize = val
      this.listAxios()
    },
    getProvince (val) {
      this.queryForm.province = val
    },
    getCity (val) {
      this.queryForm.city = val
    },
    getArea (val) {
      this.queryForm.area = val
    },
    // 出库类型
    orderStatus () {
      this.axios
        .post(
          'order/v1/internal/delivery/config/list',
          {
            request: {
              deliveryName: '',
              orgCode: sessionStorage.getItem('orgCode'),
              pageNo: 1,
              pageSize: 999
            }
          },
          {
            headers: {
              isLoading: false
            }
          }
        )
        .then((res) => {
          if (res.code == 0) {
            this.status = res.data.list
          } else {
            this.$message.error(res.message)
          }
        })
    },
    // 重置搜索数据
    reset () {
      this.queryForm = {
        info: '',
        state: '',
        type: '',
        identifier: '',
        province: '',
        city: '',
        area: '',
        department: null,
        date: []
      }

      this.listAxios('1')
    },
    is_null (content) {
      if (
        content + '' != '' &&
        content + '' != 'undefined' &&
        content + '' != 'null' &&
        content + '' != '请选择'
      ) {
        return false
      } else {
        return true
      }
    }
  }
}
</script>

<style scoped lang="scss">
.trackingNode {
  height: 300px;
  overflow-y: scroll;
  display: flex;
}
.logHeader {
  .images {
    display: inline-block;
    vertical-align: middle;
    // width: 120px;
    height: 60px;
  }

  span {
    display: inline-block;
    vertical-align: middle;
    margin-left: 20px;
  }
}
/deep/.el-tabs__header {
  margin: 0;
}
.tab {
  margin-top: 20px;
  background: #fff;
  padding: 0px 10px;
  border-radius: 10px 10px 0px 0px;
}
.characteristic {
  color: #ff0000;
}
/deep/.distpicker-address-wrapper select {
  padding: 0rem 0.75rem;
  height: 30px;
  line-height: 30px;
  font-size: 15px;
}
/deep/ .expanded {
  background: #f5f7fa;
  color: #000;
}
/deep/.el-table__expanded-cell[class*="cell"] {
  padding: 0px 50px;
}
.header {
  display: flex;
  justify-content: space-between;
  padding-bottom: 10px;
  span {
    font-size: 15px;
  }
  p {
    font-size: 12px;
    color: #2d7edf;
  }
  p:hover {
    cursor: pointer;
  }
}
.inquiry {
  background: #fff;
  padding: 10px 10px 0 10px;
  // .el-form {
  //   margin-top: 10px;
  // }
}
/deep/.el-table__expand-icon > .el-icon {
  color: #ccc;
}
.selectDate {
  display: inline-block;
  margin-right: 20px;
  span {
    display: inline-block;
    font-size: 15px;
    margin-right: 15px;
    vertical-align: middle;
  }
  .picker {
    display: inline-block;
    vertical-align: middle;
  }
  /deep/.el-input__inner {
    width: 250px;
    height: 28px;
    line-height: 28px;
  }

  /deep/ .el-date-editor .el-range__icon {
    line-height: 23px;
  }
  /deep/ .el-date-editor .el-range-separator {
    line-height: 23px;
  }
  /deep/.el-date-editor .el-range__close-icon {
    line-height: 22px;
  }
}
.table {
  margin: 10px 0 20px;
  /deep/ .el-input--suffix .el-input__inner {
    background: #409eff;
    color: #fff;
    width: 104px;
    box-shadow: none;
  }
  /deep/ .el-button {
    padding: 8px 10px;
  }
}
/deep/.el-table thead {
  color: #2d7edf;
  text-align: center;
  .cell {
    text-align: center;
  }
}
.operation {
  display: inline-block;
  margin-left: 20px;
  img {
    width: 20px;
    height: 20px;
  }
}
/deep/.el-table td,
.el-table th {
  text-align: center;
}
.page {
  text-align: right;
  width: 100%;
  background: #f5f5f5;
  padding-right: 20px;
  position: fixed;
  bottom: 0px;
  right: 0px;
  z-index: 1000;

  span {
    font-size: 14px;
    color: #666;
    display: inline-block;
    margin-left: 10px;
  }

  .el-pagination {
    display: inline-block;
    vertical-align: middle;
  }
}

.demo-table-expand {
  font-size: 0;
}
.demo-table-expand label {
  width: 200px;
  color: #99a9bf;
}
.demo-table-expand .el-form-item {
  margin-right: 0;
  margin-bottom: 0;
  width: 50%;
  text-align: left;
}
/deep/.el-table__row:hover {
  color: rgb(45, 125, 223);
}
.btn {
  span {
    display: inline-block;
    color: rgb(45, 125, 223);
    margin-right: 10px;
  }
}
.btn:hover {
  cursor: pointer;
}
/deep/.el-dialog__body {
  padding: 0px 20px 10px;
  color: #606266;
  font-size: 14px;
  word-break: break-all;
}
.totalNum {
  height: 30px;
  line-height: 30px;
  text-align: right;
  color: #409eff;
  font-size: 15px;
  font-weight: 600;
}
.selectTree {
  width: 250px;
  display: inline-block;
  vertical-align: middle;
  margin-right: 10px;
}
/deep/.vue-treeselect {
  height: 28px;
}
/deep/.vue-treeselect--searchable .vue-treeselect__input-container {
  height: 28px;
  line-height: 28px;
  width: 100%;
}
/deep/.vue-treeselect__single-value {
  font-size: 14px;
  line-height: 28px;
}
/deep/.vue-treeselect__menu-container {
  font-size: 15px;
}
/deep/.vue-treeselect__multi-value-item {
  height: 20px;
  line-height: 20px;
  padding: 0;
}
/deep/.vue-treeselect__input {
  height: 26px;
  line-height: 26px;
  outline: none;
  border: none;
  padding: 0;
}
/deep/.vue-treeselect__placeholder {
  font-size: 10px;
  line-height: 28px;
}
/deep/.vue-treeselect--has-value .vue-treeselect__multi-value {
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/deep/.vue-treeselect__control {
  height: 28px;
}
.btns {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.gift {
  display: inline-block;
  text-align: center;
  width: 54px;
  height: 24px;
  background: #feebeb;
  border-radius: 4px;
  margin-left: 25px;
  font-size: 14px;
  font-weight: 400;
  color: #F33F3F;
  line-height: 23px;
  box-sizing: border-box;
}
</style>
